package top.majuan.springboot3.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.majuan.springboot3.base.PageBean;
import top.majuan.springboot3.base.R;
import top.majuan.springboot3.entity.TbGamepublisher;
import top.majuan.springboot3.entity.TbSoftwaretype;
import top.majuan.springboot3.service.TbGamepublisherService;
import top.majuan.springboot3.vo.PageVo;

import java.util.List;

@RestController
@RequestMapping("/gamepublisher")
@RequiredArgsConstructor
public class TbGamepublisherController {
    public final TbGamepublisherService tbGamepublisherService;

    @GetMapping("/queryAll")
    public R<PageVo<TbGamepublisher>> queryAll(PageBean pageBean, TbGamepublisher tbGamepublisher) {
        return tbGamepublisherService.queryPage(pageBean, tbGamepublisher);
    }

    @GetMapping("/{pn}/{ps}")
    public R<PageVo<TbGamepublisher>> queryPage(@PathVariable("pn") Long pageNumber, @PathVariable("ps") Long pageSize, TbGamepublisher tbGamepublisher) {
        return tbGamepublisherService.queryPage(PageBean.instance(pageNumber, pageSize), tbGamepublisher);
    }
    @PostMapping
    public R<String> insert(@RequestBody TbGamepublisher tbGamepublisher) {
        return tbGamepublisherService.insert(tbGamepublisher);
    }

    @GetMapping("/{id}")
    public R<TbGamepublisher> queryByid(@PathVariable("id") Integer id) {
        return tbGamepublisherService.queryByid(id);
    }
    @PutMapping ("")
    public R<String> update(@RequestBody TbGamepublisher tbGamepublisher) {
        return tbGamepublisherService.update(tbGamepublisher);
    }
    @DeleteMapping("/{id}")
    public R<String> delete(@PathVariable("id") Integer id) {
        return tbGamepublisherService.delete(id);
    }
}
